home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / Multiprocessing 2.1v2 SDK / Sample Code / MP Sort Picts 12⁄04⁄99 / Sprocket / Lib / SplashWindow.cp < prev    next >
Encoding:
Text File  |  1996-05-01  |  2.1 KB  |  88 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        SplashWindow.cp
  3.  
  4.     Contains:    a simple splash screen window
  5.                 
  6.     Written by: Dave Falkenburg
  7.     
  8.     Copyright:    © 1993-94 by Dave Falkenburg, all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.     
  12.          <6>    11/16/94    DRF        Add (StringPtr) cast to make PPCC happier.
  13.          <5>    11/12/94    DRF        Use NewColorOrBlackAndWhiteWindow.
  14.          <4>     11/8/94    DRF        Deal with a missing splash picture.
  15.          <3>     9/27/94    DRF         AppLib.h is now Sprocket.h
  16.          <2>      9/9/94    DRF        Reordered headers and removed redundant #includes.
  17.  */
  18.  
  19. #include "Sprocket.h"
  20. #include "SplashWindow.h"
  21.  
  22. #include <ToolUtils.h>
  23. #include <Resources.h>
  24.  
  25.  
  26. TSplashWindow::TSplashWindow()
  27.     {
  28.     this->CreateWindow(kNormalWindow);
  29.     }
  30.  
  31.  
  32. TSplashWindow::~TSplashWindow()
  33.     {
  34.     if (fSplashPicture)
  35.     {
  36.         SetWindowPic(fWindow,NULL);
  37.         DisposeHandle((Handle) fSplashPicture);
  38.     }
  39.  
  40.     this->Close();
  41.     }
  42.  
  43.  
  44. WindowPtr
  45. TSplashWindow::MakeNewWindow(WindowPtr behindWindow)
  46.     {
  47.     GrafPtr        oldPort;
  48.     Rect        splashPictRect,windowRect;
  49.     WindowPtr    splashWindow;
  50.     
  51.     GetPort(&oldPort);
  52.  
  53.     fSplashPicture = GetPicture(kSplashPictureID);
  54.     
  55.     if (fSplashPicture)
  56.         {
  57.         MoveHHi((Handle) fSplashPicture);                        //    get it out of the way
  58.         splashPictRect = (**fSplashPicture).picFrame;
  59.         }
  60.     else
  61.         SetRect(&splashPictRect,0,0,0,0);
  62.         
  63.     //    normalize the rectangle
  64.     OffsetRect(&splashPictRect,-splashPictRect.left,-splashPictRect.top);
  65.  
  66.     //    center it on the main screen
  67.     windowRect = splashPictRect;
  68.     OffsetRect(&windowRect,((qd.screenBits.bounds.right-windowRect.right) >> 1),((qd.screenBits.bounds.bottom-windowRect.bottom) >> 1));
  69.     
  70.     splashWindow = NewColorOrBlackAndWhiteWindow(nil,&windowRect,(StringPtr) "\p",false,dBoxProc,behindWindow,false,(long) this);
  71.  
  72.     if (fSplashPicture)
  73.         {
  74.         DetachResource((Handle) fSplashPicture);    // need to do so we don’t botch the resource map after closing
  75.         SetWindowPic(splashWindow,fSplashPicture);    // in case an Alert comes up
  76.         }
  77.         
  78.     ShowWindow(splashWindow);
  79.     SetPort(splashWindow);
  80.     BeginUpdate(splashWindow);                    //    avoid a flashing update event later
  81.         if (fSplashPicture)
  82.             DrawPicture(fSplashPicture,&splashPictRect);
  83.     EndUpdate(splashWindow);                    //    avoid a flashing update event later
  84.  
  85.     SetPort(oldPort);
  86.     return splashWindow;
  87.     }
  88.